package com.ocom.payhandle.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.common.entity.typehandler.EntityCcbPosInfo;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.enums.MasterSlaveEnum;
import com.ocom.mysql.aspect.DataSourceAspect;
import com.ocom.payhandle.dao.IDaoCcbPosInfo;
import com.ocom.payhandle.service.CcbPosInfoService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 智慧生活柜台信息 服务实现类
 * </p>
 *
 * @author js
 * @since 2023-10-04
 */
@Service
public class CcbPosInfoServiceImpl extends ServiceImpl<IDaoCcbPosInfo, EntityCcbPosInfo> implements CcbPosInfoService {

    @Override
    @DataSourceAspect(type = DataSourceEnum.PART_DB, isMaster = MasterSlaveEnum.SLAVE)
    public EntityCcbPosInfo getDeviceInfo(Long companyId, String machNo) {
        QueryWrapper<EntityCcbPosInfo> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("com_id",companyId);
        queryWrapper.eq("device_no",machNo);
        queryWrapper.orderByDesc("update_time");
        queryWrapper.last("limit 1");
        return this.getOne(queryWrapper);
    }
}
